import leancloud
import datetime
leancloud.init("FuEKBAKt7fr6CnVTfMVXKyMm-gzGzoHsz", "9Gw1lGPn1fgxJ3gKw04BltIU")
raw_data = leancloud.Object.extend("RawData")
query = raw_data.query
query.equal_to("event_name", "2019-nCoV")
query.greater_than_or_equal_to("time", datetime.datetime(2020, 2, 27, 22, 42))
query.limit(1000)
l = query.find()
for f in l:
    time = f.get("time")
    print(time)
    data = f.get("data")
    path = '../dataset/every_hour_raw_data/'
    path2 = '../dataset/every_day_raw_data/'
    filename = ''
    for temp in (str(time.month),
                 str(time.day),
                 str(time.hour),
                 str(time.minute),
                 str(time.second)):
        if len(temp) == 1:
            temp = '0'+temp
        filename += temp
    filename += '.txt'
    with open(path + filename, 'w') as f:
        f.write(data)
    if filename[4:6] == '00':
        with open(path2 + filename, 'w') as f:
            f.write(data)